 <?php
 if (!$user_id) {
	echo	'<div class="loginForm">
        <form method="post" action="/login.php" id="login-form">        
		<h3>Đăng nhập hệ thống</h3>
        <p>
            <label for="">Tài khoản</label>
            <input type="text" id="n" name="n" />        </p>

        <p>
            <label for="">Mật khẩu</label>
            <input type="password" id="p" name="p" />        </p>

        <p>

            <label for="PartnerLoginForm_rememberMe">
				<input type="checkbox" value="1" id="mem" name="mem" class="input-remember" />                Ghi nhớ mật khẩu
            </label>
        </p>

        <p>
            <a href="/registration.php">Đăng ký tài khoản</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="users/skl.php?continue">Quên mật khẩu?</a>
        </p>

        <p style="margin-bottom: 0pt;">
            <input type="submit" value="Đăng nhập"/>
        </p>
        </form>    
	</div>';
}	
##### CHUYÊN MỤC DIỄN ĐÀN #####
 echo '<div class="phdr-top"><b>Thông Báo</b></div>';$req = mysql_query("SELECT * FROM `forum` WHERE `type` = 't' and kedit='0' AND `close`!='1' ORDER BY `time` DESC LIMIT 5");
while ($arr = mysql_fetch_array($req)) {
$q3 = mysql_query("select `id`, `refid`, `text` from `forum` where type='r' and id='" . $arr['refid'] . "'");
$razd = mysql_fetch_array($q3);
$q4 = mysql_query("select `id`, `refid`, `text` from `forum` where type='f' and id='" . $razd['refid'] . "'");
$frm = mysql_fetch_array($q4);
$frm = mysql_fetch_array($q4);
$nikuser = mysql_query("SELECT `from`,`id`, `time` FROM `forum` WHERE `type` = 'm' AND `close` != '1' AND `refid` = '" . $arr['id'] . "'ORDER BY time DESC");
$colmes1 = mysql_num_rows($nikuser);
$cpg = ceil($colmes1 / $kmess);
$nam = mysql_fetch_array($nikuser);
$arr['text'] = html_entity_decode($arr['text'],ENT_QUOTES,'UTF-8');
$class = '';
if ($arr['hot'] == 1) $class = 'hot';
elseif ($arr['hot'] == 2) $class = 'new';
elseif ($arr['hot'] == 3) $class = 'update';
echo '<div class="embed_box '. $class .'"><div class="meta_box"><img alt="" src="images/dot.gif" />';
echo '&nbsp;<a href="/forum/index.php?id=' . $arr['id'] . ($cpg > 1 && $_SESSION['uppost'] ? '&amp;clip&amp;page=' . $cpg : '') . '">' . bbcode::tags($arr['text']) . '</a>';
echo '</div></div>';
}
##### HẾT CHỦ ĐỀ MỚI #####
echo '<div class="phdr"><b>Sản Phẩm &amp; Dịch Vụ</b></div>';
echo '<div style="clear: both;"></div><div class="dichvu">';
echo '<div class="ldichvu">
            <a href="http://tiennhanh.com/users/cliphot.php"><img alt="" src="images/icon-ban-clip.jpg"/></a>
			<div>
				<a href="http://tiennhanh.com/users/cliphot.php">Bán Clip: Ứng dụng xem Clip cho Mobile</a>
				<p>Hỗ trợ: Java, Android, IOS</p>
				<p>Tỷ lệ chia sẻ: 80%</p>
			</div>
        </div>';
echo '<div class="ldichvu">
            <a href="http://tiennhanh.com/users/banner.php"><img alt="" src="images/icon-code-ban-clip.jpg" /></a>
			<div>
				<a href="http://tiennhanh.com/users/banner.php">Code Banner</a>
				<p>Tự động xuất hiện các banner quảng cáo hấp dẫn bán ứng dụng xem clip</p>
			</div>
		</div>';
echo '<div class="ldichvu">
            <a href="http://tiennhanh.com/users/cliphot.php"><img alt="" src="images/icon-phan-phoi-game.jpg"/></a>
			<div>
				<a href="http://tiennhanh.com/users/cliphot.php">Phân phối Game</a>
				<p>Hỗ trợ: Java, Android, IOS</p>
				<p>Đang cập nhật</p>
			</div>
        </div>';
echo '<div class="ldichvu">
            <a href="http://tiennhanh.com/users/cliphot.php"><img alt="" src="images/icon-tien-ich.jpg" /></a>
			<div>
				<a href="http://tiennhanh.com/users/cliphot.php">Tiện Ích</a>
				<p>Nâng cao hiệu quả kinh doanh với các công cụ hỗ trợ từ Tiền Nhanh</p>
				<p>Đang cập nhật</p>
			</div>
		</div>';
echo '</div><div style="clear: both;"></div>';
########### CHATBOX #####################
 
    echo '<div class="phdr"><b>Chat Box</b> (' . counters::guestbook() . ')</div>';
    if (($user_id || $set['mod_guest'] == 2) && !isset($ban['1']) && !isset($ban['13'])) {
        echo '<div class="gmenu"><form name="form" action="guestbook/index.php?act=say" method="post">';
        if (!$user_id)
            echo $lng['name'] . ' (max 25):<br/><input type="text" name="name" maxlength="25"/><br/>';
        echo '<b>' . $lng['message'] . '</b> <small>(max 5000)</small>:<br/>';
        if (!$is_mobile)
            echo bbcode::auto_bb('form', 'msg');
        echo '<textarea rows="' . $set_user['field_h'] . '" name="msg"></textarea><br/>';
        if ($set_user['translit'])
            echo '<input type="checkbox" name="msgtrans" value="1" />&nbsp;' . $lng['translit'] . '<br/>';
        if (!$user_id) {
// CAPTCHA для гостей
            echo '<img src="captcha.php?r=' . rand(1000, 9999) . '" alt="' . $lng['captcha'] . '"/><br />';
            echo '<input type="text" size="5" maxlength="5"  name="code"/>&#160;' . $lng['captcha'] . '<br />';
        }
        echo '<input type="submit" name="submit" value="' . $lng['sent'] . '"/></form></div>';
    } else {
        echo '<div class="rmenu">' . $lng['access_guest_forbidden'] . '</div>';
    }
    if (isset($_SESSION['ga']) && $rights >= "1") {
        $req = mysql_query("SELECT COUNT(*) FROM `guest` WHERE `adm`='1'");
    } else {
        $req = mysql_query("SELECT COUNT(*) FROM `guest` WHERE `adm`='0'");
    }
    $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `guest` WHERE `adm`='" . (isset($_SESSION['ga']) ? 1 : 0) . "'"), 0);
    if ($total) {
        if (isset($_SESSION['ga']) && $rights >= "1") {
// Запрос для Админ клуба
            $req = mysql_query("SELECT `guest`.*, `guest`.`id` AS `gid`, `users`.`rights`, `users`.`lastdate`, `users`.`sex`, `users`.`status`, `users`.`datereg`, `users`.`id`
FROM `guest` LEFT JOIN `users` ON `guest`.`user_id` = `users`.`id`
WHERE `guest`.`adm`='1' ORDER BY `time` DESC LIMIT 5");
        } else {
// Запрос для обычной Гастивухи
            $req = mysql_query("SELECT `guest`.*, `guest`.`id` AS `gid`, `users`.`rights`, `users`.`lastdate`, `users`.`sex`, `users`.`status`, `users`.`datereg`, `users`.`id`
FROM `guest` LEFT JOIN `users` ON `guest`.`user_id` = `users`.`id`
WHERE `guest`.`adm`='0' ORDER BY `time` DESC LIMIT 5");
        }
		global $rootpath;
        $i = 0;
        while (($res = mysql_fetch_assoc($req)) !== false) {
            $text = '';
            echo $i % 2 ? '<div class="list2">' : '<div class="list1">';
            if (empty($res['id'])) {
// Запрос по гостям
                $req_g = mysql_query("SELECT `lastdate` FROM `cms_guests` WHERE `session_id` = '" . md5($res['ip'] . $res['browser']) . "' LIMIT 1");
                $res_g = mysql_fetch_assoc($req_g);
                $res['lastdate'] = $res_g['lastdate'];
            }
// Время создания поста
            $text = ' <span class="gray">(' . functions::display_date($res['time']) . ')</span>';
            if ($res['user_id']) {
// Для зарегистрированных показываем ссылки и смайлы
                $post = functions::checkout($res['text'], 1, 1);
                if ($set_user['smileys'])
                    $post = functions::smileys($post, $res['rights'] >= 1 ? 1 : 0);
            } else {
// Для гостей обрабатываем имя и фильтруем ссылки
                $res['name'] = functions::checkout($res['name']);
                $post = functions::antilink(functions::checkout($res['text'], 0, 2));
            }
            if ($res['edit_count']) {
// Если пост редактировался, показываем кем и когда
                $post .= '<br /><span class="gray"><small>Изм. <b>' . $res['edit_who'] . '</b> (' . functions::display_date($res['edit_time']) . ') <b>[' . $res['edit_count'] . ']</b></small></span>';
            }
            if (!empty($res['otvet'])) {
// Ответ Администрации
                $otvet = functions::checkout($res['otvet'], 1, 1);
                if ($set_user['smileys'])
                    $otvet = functions::smileys($otvet, 1);
                $post .= '<div class="reply"><b>' . $res['admin'] . '</b>: (' . functions::display_date($res['otime']) . ')<br/>' . $otvet . '</div>';
            }
            if ($rights >= 6) {
                $subtext = '<a href="guestbook/index.php?act=otvet&amp;id=' . $res['gid'] . '">' . $lng['reply'] . '</a>' .
                        ($rights >= $res['rights'] ? ' | <a href="guestbook/index.php?act=edit&amp;id=' . $res['gid'] . '">' . $lng['edit'] . '</a> | <a href="guestbook/index.php?act=delpost&amp;id=' . $res['gid'] . '">' . $lng['delete'] . '</a>' : '');
            } else {
                $subtext = '';
            }
			echo '<div id="_comment_' . $i . '" class="comment-item">
                    <div class="avatar">';
			if (file_exists(($rootpath . 'files/users/avatar/' . $res['user_id'] . '.png'))) {
				echo '<img src="../files/users/avatar/' . $res['user_id'] . '.png" width="32" height="32" alt="' . $res['name'] . '" />';
			}else{
				echo '<img src="http://tiennhanh.com/images/empty.png" width="32" height="32" alt="' . $res['name'] . '" />';
			}
			echo '</div>
					<p>
						<span class="nonchange"> 
							<b style="color: rgb(24, 83, 140) ! important;">' . $res['name'] . '</b>
							<span class="comment-time"> 
								<span class="gray">(' . functions::display_date($res['time']) . ')</span>
							</span> 
						</span>
						<span class="comment-content _contentComment">' . $post . '</span>
					</p>
			</div>';
				                
			/*
            $arg = array(
                'header' => $text,
                'body' => $post,
                'sub' => $subtext
            );
            echo functions::display_user($res, $arg);*/
            echo '</div>';
            ++$i;
        }
    } else {
        echo '<div class="menu"><p>' . $lng['guestbook_empty'] . '</p></div>';
    }
?>